import xadmin
from .models import *


class ArticleModelConfig(object):
    list_display = ['title', 'content', 'read_num', 'fav_num', 'comment_num', 'type',
                    'category', 'update_at']
    search_fields = ['title', 'content', 'read_num', 'fav_num', 'comment_num', 'type']
    list_filter = ['title', 'content', 'read_num', 'fav_num', 'comment_num', 'type',
                   'category', 'update_at']
    ordering = ['-read_num']
    # show_detail_fields = ['name', 'desc']
    # exclude = ['click_nums', 'fav_num']
    # list_editable = ['desc', 'degree']
    readonly_fields = ['read_num', 'comment_num', 'fav_num', 'click_num', 'uuid']
    show_bookmarks = False
    model_icon = 'fa fa-window-maximize'


class PersonCategoryModelConfig(object):
    list_display = ['user', 'name', 'create_at', 'update_at']
    search_fields = ['user', 'name']
    list_filter = ['user', 'name', 'create_at', 'update_at']
    show_bookmarks = False


class TagModelConfig(object):
    list_display = ['user', 'name', 'create_at', 'update_at']
    search_fields = ['user', 'name']
    list_filter = ['user', 'name', 'create_at', 'update_at']
    show_bookmarks = False


class BlogCommentsConfig(object):
    list_display = ['user', 'article', 'comment', 'create_at', 'update_at']
    search_fields = ['user', 'article', 'comment']
    list_filter = ['user', 'article', 'comment', 'create_at', 'update_at']
    show_bookmarks = False


class BlogCategoryConfig(object):
    list_display = ['category', 'create_at', 'update_at']
    search_fields = ['category']
    list_filter = ['category', 'create_at', 'update_at']
    show_bookmarks = False


class TypeCategoryConfig(object):
    list_display = ['type', 'create_at', 'update_at']
    search_fields = ['type']
    list_filter = ['type', 'create_at', 'update_at']
    show_bookmarks = False


xadmin.site.register(ArticleModel, ArticleModelConfig)
xadmin.site.register(PersonCategoryModel, PersonCategoryModelConfig)
xadmin.site.register(TagModel, TagModelConfig)
xadmin.site.register(BlogComments, BlogCommentsConfig)
xadmin.site.register(BlogCategoryModel, BlogCategoryConfig)
xadmin.site.register(TypeCategoryModel, TypeCategoryConfig)
